
package com.comtop.test;

import java.io.File;
import java.text.MessageFormat;

public class FileRecursion {
    
    /**
     * @param args
     */
    public static void main(String[] args) {
        File dir = new File("D:/eclipse320/workspace/ServerManager/ServerManager/WEB-INF/lib");
        traverse(dir);
    }
    
    public static void traverse(File dir) {
        File[] listFiles = dir.listFiles();
        for (File file : listFiles) {
            if (file.isDirectory()) {
                traverse(file);
            } else {
                println(file);
            }
        }
    }
    
    public static void println(File file) {
        String fileName = file.getName();
        String pattern = "../lib/{0};";
        Object arguments[] = new String[] { fileName };
        // String pattern =
        // "mvn install:install-file -Dfile={0} -DgroupId=org.directwebremoting -DartifactId={1} -Dversion={2} -Dpackaging=jar";
        // Object arguments[] = new String[] { fileName, fileName.split("-")[0],
        // fileName.replaceAll(".jar", "") };
        String code = MessageFormat.format(pattern, arguments);
        System.out.print(code);
    }
}
